package appconfig

import (
	"fmt"
	"github.com/spf13/viper"
)

type appConfig struct {
	MysqlConfig
	RedisConfig
	AliYun
}
type MysqlConfig struct {
	User     string
	Password string
	Hort     string
	Post     int
	Database string
}
type RedisConfig struct {
	Addr     string
	Password string
	DB       int
}
type AliYun struct {
	Key  string
	Keys string
}

var Conf appConfig

func Init() {
	viper.SetConfigFile("../appconfig/dev.yaml")
	err := viper.ReadInConfig()
	if err != nil {
		fmt.Println("配置文件读取失败")
	}
	err = viper.Unmarshal(&Conf)
	if err != nil {
		fmt.Println("配置文件下载失败")
	}
	fmt.Println("配置文件读取成功")
}
